@import '~/common/style/index.scss';

$avatar-prefix-cls: #{$cui-prefix}-avatar;

$presence-tag-cls: #{$cui-prefix}-presence-tag;

@mixin avatar-size($size, $font-size) {
    width: $size;
    height: $size;
    line-height: $size;
    border-radius: 50%;
    flex-shrink: 0;
    font-size: calc($size/2) - 4;
    // &-string {
    //   position: absolute;
    //   left: 50%;
    //   transform-origin: 0 center;
    // }

    &.#{$avatar-prefix-cls}-icon {
        font-size: $font-size;

        //   > .#{$iconfont-css-prefix} {
        //     margin: 0;
        //   }
    }
}

.#{$avatar-prefix-cls}-wrap {
    position: relative;
    width: fit-content;
    &>span{
        display: flex;
        justify-content: center;
        align-items: center;
    }
}

.#{$avatar-prefix-cls} {
    position: relative;
    display: inline-block;
    overflow: visible;
    color: $avatar-color;
    white-space: nowrap;
    text-align: center;
    vertical-align: middle;
    background: $avatar-bg;

    box-sizing: border-box;
    margin: 0;
    padding: 0;
    color: $text-color;
    font-size: $font-size-base;
    font-variant: 18px;
    line-height: $line-height-base;
    list-style: none;
    font-feature-settings: 'tnum';
    // cursor: pointer;
    user-select: none;

    display: inline-block;
    word-wrap: break-word;
    white-space: break-spaces;
    justify-content: center;
    border-radius: 50%;
    &-hasImage{
        background: transparent;
    }
    &-image {
        background: transparent;
        width: 100%;
        /* flex: 1; */
        display: block;
        height: 100%;
        position: relative;
        overflow: hidden;
        border-radius: 50%;
        &>img {
            display: block;
            width: 100%;
            height: 100%;
            object-fit: cover;
        }
    }

    .#{$cui-prefix}-image-img {
        display: block;
        width: 100%;
        height: 100%;
    }
    &-string{
        padding: 0 4px;
        overflow: hidden;
        white-space: nowrap;
        display: flex;
        position: absolute;
        box-sizing: border-box;
        width: 100%;

        height: 100%;
        align-items: center;
        justify-content: center;

        &>div{
            overflow: hidden;
        }
    }

    @include avatar-size($avatar-size-base, $avatar-font-size-base);

    &-lg {
        @include avatar-size($avatar-size-lg, $avatar-font-size-lg);
    }

    &-sm {
        @include avatar-size($avatar-size-sm, $avatar-font-size-sm);
    }

    &-square {
        border-radius: $avatar-border-radius;
        .#{$avatar-prefix-cls}-image{
            border-radius: $avatar-border-radius;
        }
    }
   
    &-dark{
        background: $blue-6;
        .#{$avatar-prefix-cls}-presence-wrap{
            background-color: $gray-1;
        }
    }

    &-presence-wrap{
        border-radius: 50%;
        width: 10px;
        height: 10px;
        background-color: $gray-98;
        text-align: center;
        position: absolute;
        line-height: 15px;
        right: calc(14.65% - 5px);
        bottom: calc(14.65% - 5px);
        display: flex;
        justify-content: center;
        align-items: center;
        padding: 2px;
        box-sizing: border-box;
        &>img{
            width: 100%;
            border-radius: 50%;
        }
    }
    &-presence-text{
        height: 32px;
        line-height: 32px;
        font-size: 14px;
        text-align: center;
    }
}

.#{$presence-tag-cls}-wrap {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    right: calc(14.65% - 6px);
    bottom: calc(14.65% - 6px);
    width: 12px;
    height: 12px;
    background: $gray-98;
}

.#{$presence-tag-cls} {
    width: 8px;
    height: 8px;
    background: $green-5;
    border-radius: 50%;
}